<template>
  <div class="login">
    <h2>登录界面</h2>
    <form @submit.prevent="login" class="login-form">
      <div class="form-group">
        <label for="username">用户名:</label>
        <input type="text" id="username" v-model="username" required />
      </div>

      <div class="form-group">
        <label for="password">密码:</label>
        <input type="password" id="password" v-model="password" required />
      </div>
      <div class="form-group">
        <button type="submit" class="submit-button">登录</button>
      </div>
    </form>
  </div>
</template>

<script>
export default {
  data() {
    return {
      username: '',
      password: ''
    };
  },
  methods: {
    login() {
      if(this.username === 'admin' && this.password === 'admin') {
        this.$router.push('/page2');
        this.$notify({
          group: 'default',
          title: '登录成功',
          text:'登录成功',
          type: 'success',
        });
      }
      else{
        this.$notify({
          group: 'default',
          title: '登录失败',
          text:'用户名或者密码错误！',
          type: 'error',
        });
      }
    }
  },
  name: 'page1'
}
</script>
<style>
.login {
  max-width: 400px;
  margin: 50px auto;
  padding: 20px;
  border:1px solid #ddd;
  border-radius: 5px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}
.login-form{
  display: flex;
  flex-direction: column;
}
.form-group{
  margin-bottom: 15px;
}
.form-group label{
  display: block;
  margin-bottom: 5px;
}
.form-group input{
  width: 90%;
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
}
.submit-button{
  background-color: #007bff;
  color: white;
  padding: 10px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: background-color 0.3s ease;
}
.submit-button:hover{
  background-color: #0056b3;
}

</style>